﻿Imports System.Data.OleDb
Public Class AddNewApps
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_submit.Click

        Dim OleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        OleDbConn.Open()
        Dim sqlString As String = "INSERT into [Photo Sharing AppsList] (AppsName,Descripton,Picture) VALUES (@f1,@f2,@f3)"
        Dim cm As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlString, OleDbConn)
        cm.Parameters.AddWithValue("@f1", tb_AppsName.Text)
        cm.Parameters.AddWithValue("@f2", tb_Descripton.Text)
        cm.Parameters.AddWithValue("@f3", "images/" & fup_Picture.FileName)
        cm.CommandType = CommandType.Text
        cm.ExecuteNonQuery()
        Dim pictureFolder As String = Request.MapPath("images")
        fup_Picture.SaveAs(pictureFolder & "/" & fup_Picture.FileName)
        OleDbConn.Close()
        cm.Dispose()
        OleDbConn.Dispose()
        Response.Redirect("Default.aspx")

    End Sub
End Class